package com.dcbeida.utils;

import android.text.InputFilter;
import android.text.Spanned;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by hp on 2016/8/24.
 */
public class PasswordFilter implements InputFilter {

    // 只允许字母和数字
    String regEx = "[^a-zA-Z0-9]";

    @Override
    public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(source);
        String rs = m.replaceAll("").trim();
        return rs;
    }
}
